{include file="public_iframe:head"}
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/lang/zh-cn/zh-cn.js"></script>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>信息分类编辑</h5>
            <div class="ibox-tools" style="margin-top: -9px;">
                <a href="javascript:history.go(-1);" class="btn btn-primary"><i class="fa fa-arrow-left"></i> 返回</a>
            </div>
        </div>
        <div class="ibox-content">
            <form action="" method="post" enctype="multipart/form-data" id="brandForm" class="form-horizontal">
                <input type="hidden" name="id" value="{$da.id?$da.id:'';}">
                <div class="form-group">
                    <label class="col-sm-2 control-label">分类名称</label>
                    <div class="col-sm-6">
                        <input type="text" name="name" id="name" value="{$da.name?$da.name:'';}" class="form-control" placeholder="分类名称" disabled >
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">价格&nbsp;&nbsp;(1条)</label>
                    <div class="col-sm-6">
                        <input type="text" name="price" id="price" value="{$da.price?$da.price:'';}" class="form-control" placeholder="价格" >
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <div class="col-sm-4 col-sm-offset-2">
                        <a href="JavaScript:void(0);" onclick="Submit();" class="btn btn-primary" id="submit">提交</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    function Submit(){
        var formData = new FormData();
        var id = $('input[name="id"]').val();
        var name = $('input[name="name"]').val();
        var price = $('input[name="price"]').val();
        
        formData.append('id',id);
        formData.append('price',price);

        if(isNaN(price)){
            parent.layer.alert('输入不是数字!',{
                skin: 'layui-layer-molv' //样式类名
                ,closeBtn: 0
            });
            return false;
        }

        $.ajax({
            url:"{:url('Loan/category')}",
            type:'POST',
            data:formData,
            async:false,
            processData:false,
            contentType:false,
            success:function(result) {
                if(result.code == '0'){
                    parent.layer.alert(result.msg,{
                        skin: 'layui-layer-molv' //样式类名
                        ,closeBtn: 0
                    });
                }else{
                    parent.layer.msg(result.msg,{
                        icon:1,
                        time:1000,
                    },
                    function (index, item) {
                        location.href = result.url;
                    });
                }
            }
        });
    }
</script>
</body>

</html>